<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>天气案例_监测属性_简写</title>
  <script src="../js/vue.js"></script>
</head>


<!-- 
 -->

<body>

  <div id="root">
    <h1>今天的天气:{{info}}</h1>
    <button @click="isHot = !isHot">切换</button>
  </div>

  <script type="text/javascript">
    // 阻止vue启动的时候产生生产提示
    Vue.config.productionTip = false;

    const vm = new Vue({
      el: '#root',
      data: {
        isHot: true,
      },
      computed: {
        info() {
          return this.isHot ? '炎热' : '凉爽'
        },
      },
      watch: {
       isHot(newVal, oldVal) {
         console.log(newVal, oldVal)
       }
      }
    })

    // vm.$watch('isHot', function(newVal, oldVal) {
    //   console.log(newVal, oldVal)
    // })

  </script>

</body>

</html>